//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using CommunityServer.Components;

namespace CommunityServer.Files.Components
{
	/// <summary>
	/// Base class for all File Gallery Syndication feeds
	/// </summary>
	public abstract class BaseFileGallerySyndicationHandler : BaseSyndicationHandler
	{
		public BaseFileGallerySyndicationHandler() { }

		private FileGalleryConfiguration _fileGalleryConfig;
		protected FileGalleryConfiguration FileGalleryConfig
		{
			get
			{
				if (_fileGalleryConfig == null)
					_fileGalleryConfig = FileGalleryConfiguration.GetConfig();

				return _fileGalleryConfig;
			}
		}

		/// <summary>
		/// The length of time the feed should be cached in seconds.
		/// </summary>
		protected override int CacheTime
		{
			get { return CSCache.SecondFactorCalculate(FileGalleryConfig.RssCacheWindowInSeconds); }
		}
		
		protected override string BaseUrl
		{
			get { return Globals.HostPath(Context.Request.Url); }
		}

		protected override Section GetCurrentSection
		{
			get { return Folders.GetFolder(CSContext.Current.ApplicationKey); }
		}

		protected Folder CurrentFolder
		{
			get { return CurrentSection as Folder;}
		}


	}
}
